Adaptive power cycle sequences for data recovery

ABSTRACT

The present invention relates to an apparatus, method, and/or sequence that adaptively provide the recovery of data after a power cycle sequence, wherein only minimal updates are provided for control blocks associated with the data,

This application is a continuation of application Ser. No. 15/176,156, filed Jun. 8, 2016 and issued as U.S. Pat. No. 10,180,887 on Jan. 15, 2019, which is a continuation of application Ser. No. 13/253,912, filed Oct. 5, 2011 and issued as U.S. Pat. No. 9,372,755 on Jun. 21, 2016, each of which is incorporated by reference herein.

BACKGROUND (1) Technical Field

The present invention relates to computer storage systems, such as data storage devices that use data recovery.

(2) Description of Related Art

Typically, a storage system experiencing power failure at the middle of a process either acquires corrupted data or loses the data in a worst case scenario. The usual technique of easy data recovery is that upon data modification, the controls and directories associated to the data are also updated. This type of technique consumes relatively larger time and bandwidth. Consequently, there is a need for efficient power cycle sequences capable of data recovery.

The directory structure of a hybrid storage system is very hierarchical. This structure includes controls and directories arranged in a linked list manner. Constant updates of these directories are not only very time and bandwidth consuming but moreover, update synchronization is difficult considering the different directory levels that are contained in different memory blocks. Consequently, there is a need for sequences that are sufficiently adaptive to determine when these directories need to be updated and when the directories require no updates, thereby minimizing directory updates.

Normally, the control information is contained in the control blocks alone. Putting the controls in one block allows rebuilding of all directory structures, and this rebuilding even includes the rebuilding of unrelated information. This results in the wasting of time and bandwidth during the rebuilding process. Consequently, there is a need to achieve an improved and more efficient rebuilding of control data that has been corrupted.

SUMMARY

The present invention relates to an apparatus, method, and/or sequence that adaptively provide the recovery of data after a power cycle sequence, wherein only minimal updates are provided for control blocks associated with the data.

A power outage without notification can cause data corruption and/or data loss in storage systems. An example of such causes of data corruption is when at the middle of a system update process, an unexpected power failure occurs.

Embodiments of the invention further provide an apparatus, methods, and/or sequences which minimize data corruption and/or loss, and can recover the aforementioned corrupted and/or lost data by utilizing (i) data relocation, (ii) preventive safe sequence of data updates, and (iii) power cycle recovery sequence.

An embodiment of the invention advantageously separates some of the necessary information and places these necessary information in the data sections, so that only the corrupted control blocks related to the corrupted data are re-built.

In one embodiment of the invention, a method for data relocation includes: providing a free section in a free list block; obtaining an old physical block address (PBA) of an associated LBA of a used section that is currently storing old data; setting the old PBA of the used section equal to a displaced PBA of the free section; writing new data for the used section into the free section; and erasing the used section and changing the used section into a new free section. Another embodiment of the invention also provides an apparatus that can be configured to perform at least some of the above functionalities.

In another embodiment of the invention, a method for a power cycle recovery sequence, includes: providing, in a cache, a free list block comprising free list entries pointing to sections in a memory in a system; scanning the free list block to determine if each used free section is dirty, wherein a used free section that is dirty will require an update of a directory (DirBlk) and information directory block (BlkInfoDirBlk) that are associated with the used free section, and wherein each used free section stores user data; if a used free section is dirty, then performing a power cycle recovery sequence of the information directory block (BlkInfoDirBlk) and performing a power cycle recovery sequence of the directory (DirBlk); scanning each free section that is pointed by each free list entry; and if a free section is free, then performing a power cycle recovery sequence for the information directory block (BlkInfoDirBlk), and if the free section is not free, then erasing the free section. Another embodiment of the invention also provides an apparatus that can be configured to perform at least some of the above functionalities.

In another embodiment of the invention, a method of data relocation, includes: writing a new data to a free section, wherein the new data is for replacing old data in a current used section and wherein the new data includes a physical block address of the used section; determining if the new data in the free section is valid; if the new data is valid, converting the free section into the next used section with the physical block address of the current used section; and erasing the old data and converting the current used section into another free section. Another embodiment of the invention also provides an apparatus that can be configured to perform at least some of the above functionalities.

In another embodiment of the invention, a method for data recovery includes: in a power cycle recovery sequence, providing a minimal update for control blocks associated with data to be recovered. Another embodiment of the invention also provides an apparatus that can be configured to perform at least some of the above functionalities.

The above and additional advantages of the present invention will become apparent to those skilled in the art from a reading of the following detailed description when taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of an example directory structure where the directory blocks hold the addresses of non-volatile memory blocks;

FIG. 2 is a block diagram of an example directory structure of a hybrid storage system where the directory blocks hold the addresses of non-volatile memory data sections;

FIG. 3 is a flow diagram of a current recovery sequence method using the redundancy technique;

FIGS. 4A and 4B are flow diagrams that illustrate a power cycle recovery sequence in accordance with one embodiment of the present invention;

FIG. 5 is a block diagram of a layout of section indices pointing to free sections in the non-volatile memory relative to cache, in accordance with another embodiment of the invention;

FIG. 6 is a flow diagram of the power cycle recovery sequence for updating a BlkInfoDirBlk, in accordance with yet another embodiment of the invention;

FIG. 7 is a flow diagram of the power cycle recovery sequence for updating a DirBlk, in accordance with a further embodiment of the invention;

FIG. 8 is a flow diagram of a method of comparison between physical block address, in accordance with a further embodiment of the invention;

FIG. 9 is a block diagram illustrating the different cases of when to update the BlkInfoDirBlk and the DirBlk, in accordance with a further embodiment of the invention;

FIG. 10 is a block diagram of a normal operation update for a FreeLstBlk, in accordance with a further embodiment of the invention;

FIG. 11 is a block diagram of an itemized illustration of FreeLst update of FIG. 10, in accordance with a further embodiment of the invention;

FIG. 12 is a block illustration of a data relocation, in accordance with a further embodiment of the invention;

FIG. 13 is a flowchart of the data relocation process illustrated in FIG. 12, in accordance with a further embodiment of the invention; and

FIG. 14 is a block diagram of an example storage system (or device), in accordance with a further embodiment of the invention.

DETAILED DESCRIPTION OF THE INVENTION

In the following detailed description, for purposes of explanation, numerous specific details are set forth to provide a thorough understanding of the various embodiments of the present invention. Those of ordinary skill in the art will realize that these various embodiments of the present invention are illustrative only and are not intended to be limiting in any way. Other embodiments of the present invention will readily suggest themselves to such skilled persons having the benefit of this disclosure.

In addition, for clarity purposes, not all of the routine features of the embodiments described herein are shown or described. One of ordinary skill in the art would readily appreciate that in the development of any such actual implementation, numerous implementation-specific decisions may be required to achieve specific design objectives. These design objectives will vary from one implementation to another and from one developer to another. Moreover, it will be appreciated that such a development effort might be complex and time-consuming but would nevertheless be a routine engineering undertaking for those of ordinary skill in the art having the benefit of this disclosure.

A power outage without notification can cause data corruption and/or data loss in storage systems. Usually this problem is solved by an immediate update of control blocks associated with the modified data. However, this solution is time and bandwidth consuming especially in cases when the data is frequently overwritten. As will be discussed below, embodiments of the invention provide adaptive sequences or methods capable of data recovery after a power cycle sequence and involving only minimal updates of control blocks associated to the modified data.

For small end storage system, the directory structure is less complex compared to that in the hybrid storage system. FIG. 1 is a block diagram that illustrates an example of a directory structure for a small end storage system. Base block (BaseBLk) 100 contains the address of the control block (CtrlBlk) 101 which stores information such as the directories 102 (alternatively referred herein as “directory blocks 102”) holding addresses for data blocks 103. The data blocks 103 are typically non-volatile memory blocks. Each directory block (DirBlk) 102 contains entries 104 which, per entry, hold the data block addresses 105 for the data blocks 103 in a non-volatile memory. A particular data block address 105 is associated with a respective data block 103.

In comparison with that of the directory structure in FIG. 1, FIG. 2 is a block diagram that illustrates a modular and hierarchal directory structure which is efficient for a high-end, fast, hybrid storage system. The base block (BaseBlk) 200 contains pointers that point to a control block (CtrlBlk) 201. The CtrlBlk 201 contains pointers that point to a directory block (DirBlk) 202 and a free list block physical block address (FreeLstBlkOPBA) 203. The level (or number) of directory blocks can be one (1) or more, depending on the size of the storage system (also referred herein as “system”). The directory blocks 202 hold the addresses of non-volatile memory data sections 211. As described below in additional details, a data section can shift in the state from being a used data section to being a free data section, and vice versa. In the example of FIG. 2, a used data section 211 is in a data block 220 which can be, for example, a memory block in a non-volatile memory device. A non-volatile memory device can be, for example, a flashchip (i.e., flash memory device) or another suitable type of memory device. The term “flashchip” or “flash memory device” is intended to include any form of non-volatile solid-state memory, including those that use blocks of non-volatile memory cells, named flash blocks. Each memory cell (not shown) may be single or multi-level. Flash memory devices are known by those of ordinary skill in the art. A flash memory device permits memory operations, such as a write or read operation, to be performed on these flash blocks according to a protocol supported by the flash memory device. A flash memory device may be implemented by using a NAND flash memory device that complies with the Open NAND Flash Interface Specification, commonly referred to as ONFI Specification. The term “ONFI Specification” is a known device interface standard created by a consortium of technology companies, called the “ONFI Workgroup”. The ONFI Workgroup develops open standards for NAND flash memory devices and for devices that communicate with these NAND flash memory devices. The ONFI Workgroup is headquartered in Hillsboro, Oreg. Using a flash memory device that complies with the ONFI Specification is not intended to limit the embodiment(s) disclosed. One of ordinary skill in the art having the benefit of this disclosure would readily recognize that other types of flash memory devices employing different device interface protocols may be used, such as protocols compatible with the standards created through the Non-Volatile Memory Host Controller Interface (“NVMHCI”) working group. Members of the NVMHCI working group include Intel Corporation of Santa Clara, Calif, Dell Inc. of Round Rock, Tex. and Microsoft Corporation of Redmond, Wash.

The free list block physical block address (FreeLstBlkOPBA) 203 holds the physical block address (PBA) of the free list block 0 (FreeLstBlk0) 204 which is the first memory block in the chain holding the list of all non-volatile memory blocks with free sections in the system. In FIG. 2, this chain has the following example free list blocks (FreeLstBlk0 through FreeLstBlkN) where N is any suitable integer number depending on the memory size available in the system. A section 211 (or “data section” 211) is defined to be the smallest logical allocation unit in the memory which can be relocated independently. The sections can span (can be distributed among) one or more non-volatile memory device 1410 (FIG. 14), or can span one or more non-volatile memory block 220. In the example of FIG. 2, the non-volatile memory block 220 is currently shown as including the used DataSection_0, used DataSection_1, and free DataSection_2 through free DataSectionD. The system can store user data within the data sections in a single memory block 220, within data sections that is distributed among multiple memory blocks 220, within data sections that are distributed among multiple non-volatile memory devices 1410 (FIG. 14), and/or by another suitable method that stores the user data in multiple memory areas. Additionally, the terms “block” or “memory block” can also mean a section, a memory page, a flashchip block, or another type of addressable non-volatile memory area. Therefore, the terms “block” or “memory block” is not limited to just a flashchip block. A section is in its free state (i.e., a section is a “free section” or “free data section”) if the section is not associated with any logical block address (LBA) but can be associated anytime with an LBA. A section is in its used state (i.e., a section is a “used section” or “used data section”) if the section is already associated to an LBA. A free list block (e.g., free list block 204) is a non-volatile memory block holding a free section (free data section) in the system. As shown in FIG. 2, each non-volatile memory block 220 can have both used sections 211 and free sections 207.

The details of the FreeLstBlk structure (e.g., FreeLstBlk0 204) are also shown in FIG. 2. The FreeLstBlk structure holds the array of free list entries 205 (e.g., FreeLstEntry0, FreeLstEntry1, and other entries) for all the non-volatile memory blocks 220 with free sections present in the whole system. Each free list entry (FreeLstEntry) holds the section index (SecIdx) 206 that points to the free section 207 which is shown as example free data section 2 (see, “DataSection 2”) currently in the non-volatile memory block 220 (DataBlk 220) in FIG. 2. Another example free section currently in the memory block 220 is free data section D (see, “DataSection D”). These free list blocks are chained by pointers (i.e., free list block 1 208 is pointed to by next free list block physical block address (NxtFreeLstBlkPBA) 209 and so on until all the non-volatile blocks are covered.

The DirBlk 202 structure holds the array of directory entries 210 for a plurality of used data sections 211. In the example of FIG. 2, the used data sections 211 are currently used data section 0 (“DataSection 0”) and used data section 1 (“DataSection 1”) in the memory block 220. Each directory entry (DirEntry) contains the PBA (physical block address) 212 of its associated used data section 211. As mentioned above, a section is in its used state if the section is already associated to an LBA (logical block address). Every used section 211 includes its user data 213, its associated LBA 214, and a displaced PBA 215 which is the PBA of the last data section associated to the LBA 214. If directory level 1 is not enough to accommodate the total number of used data sections, a higher level can be created to accommodate the other used data sections.

The control block 201 also contains a pointer that point to an information directory block (BlkInfoDirBlk) 216. This information directory block (BlkInfoDirBlk) 216 holds the array of information entries (BlkInfoDirEntry) 217 for all the non-volatile memory blocks present in the whole system. Each entry (BlkInfoDirEntry) holds an invalid bit map (InvalidBitMap) 218 that flags whether a data section is invalid or not. A data section is in its invalid state if it is not associated to any LBA but has to be erased first before the data section can be associated with an LBA. The DataSections can be in a single non-volatile memory Blk 220 (as shown in FIG. 2) or the DataSections can span (e.g., can be distributed among) multiple Blocks 220, and/or the DataSections can span multiple non-volatile memory devices (e.g., multiple memory devices 1410 in FIG. 14), so that the system can store the user data among multiple memory areas as needed for purposes of increased storage efficiency and performance. It is also noted that the dashed arrow 221 from BlkInfoDirBlk 216 to DataBlks 220 does not represent not an actual pointer to DataBlks 220. This dashed arrow 221 instead indicates that the BlkInfoDirBlk 216 contains the various information or status of the DataBlks 220 as will be discussed below.

The importance of separating the information describing the status of the DirBlk (i.e., the presence of BlkInfoDirBlk) allows the separation of updates for each block. This separation advantageously minimizes the unwanted updates for unnecessary data, as will be discussed below, in accordance with one or more embodiments of the invention.

For the directory structure of FIG. 1, the smallest unit that a directory entry holds is one block which allows a simple data recovery sequence to be implemented as illustrated in FIG. 3. In FIG. 3, there is shown a flow diagram of a current recovery sequence method using the redundancy technique. Additional details of the recovery sequence of FIG. 3 are also described in commonly-owned and commonly-assigned U.S. Pat. No. 6,970,890. In this method, the data is first written to the recovery block (RecvryBlk) in task 300. After the write is performed, in task 301 the data is verified if there are no errors. Since the data is written to same memory block, in task 302 the memory block is first erased prior to any updates. In the event of a power loss when or after the memory block is erased, the data remains saved in the recovery block. If the memory block is already clean, the data (from the recovery block) is now written to the memory block (DataBlk) in task 303. The written data in the memory block is verified if it is error-free in task 304. Finally, in task 305 the recovery block is erased in preparation for its future use in updates as similarly described in task 300 and subsequent tasks in FIG. 3. In this technique of recovery sequence, if used solely in the directory structure of FIG. 2, the following issues will arise: (1) time consuming (latency), (2) bandwidth consuming, (3) difficulty in directory synchronization. These issues are due to a “domino effect” penalty as the result of the hierarchical nature (or tree structure) of the directory. For example, if an update is performed in a particular block level of the directory structure, an update is also required for higher block levels in the directory structure so that coherency or synchronization is maintained with other parts of the directory structure that relies on the performed update. Therefore, it would be advantageous to reduce the latency and other issues that are imposed by the tree structure of the directory. Embodiments of the present invention solve these issues as illustrated in FIGS. 4A and 4B and as discussed below.

Reference is now made to FIGS. 4A, 4B, and 5. FIGS. 4A and 4B are flow diagrams that illustrate a power cycle recovery sequence in accordance with one embodiment of the present invention. FIG. 5 is a block diagram of a layout of section indices pointing to free sections in the non-volatile memory relative to cache, in accordance with one embodiment of the invention. The major blocks involved in this power cycle recovery sequence of FIGS. 4A-4B includes the following: BlkInfoDirBlk 216 (see FIG. 2), DirBlk 202, and FreeLstBlk (e.g., the free list blocks in the chain that begins with the example free list block 204 in FIG. 2 and shown as example free list block 500 in FIG. 5). As shown in some of the various tasks in FIGS. 4A-4B, the legend “CF” means cache free list (i.e., a free list entry in a volatile memory such as, for example, a cache 1408 in FIG. 14 or another type of volatile memory device), and the legend “FS” means non-volatile memory section or flashchip section (i.e., a data section in a non-volatile memory such as, for example, the memory 1410 in FIG. 14 or another type of non-volatile memory device). When the term “cache” is used herein, it is understood by those skilled in the art that this term can also mean another suitable type of volatile memory device. When the term “flashchip” is used herein, it is understood by those skilled in the art that this term can also mean another suitable type of non-volatile memory device. In an embodiment, the memory 1410 can also be a memory array having multiple non-volatile memory devices. This power cycle recovery sequence happens during initialization when the system obtains power after a power interruption. The recovery of the BlkInfoDirBlk (block 216) and DirBlk (block 202) are dependent on the FreeLstBlk block, so that the aforementioned FreeLstBlk 500 should be made available in cache in task 400 (FIG. 4A). When the free list block 500 is made available in cache, this free list block 500 will mirror (is equal to) the corresponding free list block 500 in the non-volatile memory. This FreeLstBlk 500 was also referred to as FreeLstBlk 204 in the above discussion relating to FIG. 2.

Each FreeLstBlk contains an index (I) 501 (FIG. 5) and pointer 502. The free list entries (“F” or FreeLstEntry) of the FreeLstBlk 500 are scanned 510 starting from the entry pointed to by the index 501 (left to right) up to the pointer 502 of used free list entries, as shown in FIG. 5. The system performs this scanning procedure. For example, in FIG. 5, the FreeLstBlk 500 points to sixteen (16) free list entries (free list entries 0 through 15). The system scans these free list entries F in a volatile memory 1408 (e.g., a cache). Each of the free list entries F is associated to a free section in the non-volatile memory 1410 (e.g., a flashchip). As an example, the free list entry (FreeLstEntry0) is associated with the free section 207 as shown in FIG. 2. Assuming during the start up of power, there are, for example, twelve (12) used free sections 503 (shown as blocks F with diagonal hash marks) so that the twelve (12) used free list entries (entries 0 through 11) are candidates for removal in the free list. The system checks the aforementioned respective used free sections pointed to by each of the corresponding twelve (12) candidates 503 by scanning the aforementioned FreeLstBlk 500 in task 401. Specifically, in task 401, the system checks each respective used free section that are pointed to by a corresponding free list entry in the twelve free list entries, by a left-to-right scan 510, starting from the index 501 and up to the pointer 502.

The system further verifies if the particular used free section (associated with one of the used free list entries 0 through 11) is actually free (pre-erased or clean) in task 402. If the particular used free section is dirty (not clean or not pre-erased) in task 403, this means that the BlkInfoDirBlk (information directory block) and the DirBlk (directory block) saved in the non-volatile memory associated to that particular used free section (also in the non-volatile memory) needs to be updated because that particular used section is dirty (i.e., contains user data). This update is performed in Task 404 and Task 405. Task 404 illustrates the power cycle recovery sequence for updating the BlkInfoDirBlk and is shown in additional details in FIG. 6 below. Task 405 illustrates the power cycle recovery sequence for updating the DirBlk and is shown in additional details in FIG. 7 below.

Task 414 checks for the next free list entry among the candidates for removal, and the tasks 401 through 405 are repeated in loop 412 for the next free list entry among the candidates for removal until the last free list entry that is a candidate for removal has been processed by the tasks that start at task 401.

After the last free list entry that is a candidate for removal (from free list block 500) has been processed by the tasks that starts at task 401 (or if a particular used free section is clean in task 403), then the sequence proceeds to the tasks in FIG. 4B.

As mentioned above, the Tasks 401 to 405 in FIG. 4A loops until all the free list entries that are candidates for removal are determined. After the loop 412 (FIG. 4A) is completed, the system proceeds to the scanning 511 of the FreeLstBlk from the pointer 502 up to the free list entry pointed to by the index 501 (right to left) until it is determined or proven that the FreeLstEntries are proven to be clean as shown in FIG. 5. For example, in FIG. 5, after the FreeLstEntries 503 that are candidates for removal were replaced with the new set of free sections 504 pointed to by FreeLstEntries, the system checks the free section pointed to by the FreeLstEntry in task 406. Then in task 407, the system verifies if the free section 504 is indeed clean or erased. The system performs the task 407 for all free sections pointed to by all the FreeLstEntries F in order to make sure that FreeLstBlk 500 contains FreeLstEntries F that all points to only clean/erased free sections in non-volatile memory. If the free section 504 (in non-volatile memory) turns out to be dirty in task 408, the system erases the aforementioned free section (in non-volatile memory) in task 409 so that this free section pointed to by the FreeLstEntry F (added to free list block 500) is clean/erased (i.e., will have no user data and is not associated to an LBA); otherwise, the BlkInfoDirBlk power cycle recovery sequence of FIG. 6 is again executed in task 410. Tasks 406 through 410 loops until the section pointed to by the FreeListEntry is proven to be clean. The system then exits this process.

Reference is now again made to FIG. 4B for purposes of an additional detailed discussion. In task 406, the system checks the free section 504 that is pointed to by the particular FreeLstEntry, by performing a right to left scan 511 from the pointer 501 (FIG. 5) to the index 502. The system performs Task 406 after the FreeLstEntries 503 (FIG. 5) that are candidates for removal were replaced 512 (FIG. 5) with the new set of free sections 504 (FIG. 5) pointed to by FreeLstEntries.

In task 407, the system verifies if an aforementioned free section 504 is indeed clean (erased). In task 408, if the aforementioned free section 504 is clean, the system again executes the power cycle recovery sequence for the BlkInfoDirBlk (of FIG. 6) in task 410 and proceeds to task 411. Tasks 406 through 410 will loop 415 until the free section 504 pointed to by the FreeListEntry is proven to be clean. The system then exits this process after task 411 determines that the last free list entry in the candidates 504 for addition to the free list block 500 have been checked in task 406 through task 410.

If, in task 408, the aforementioned free section 504 is not clean (i.e., is dirty), then the system erases the aforementioned free section 504 in task 409 so that the free section 504 is clean in non-volatile memory.

Reference is now made to both FIG. 2 and FIG. 6. FIG. 6 is a flow diagram of the power cycle recovery sequence for updating a BlkInfoDirBlk (e.g., block 216 in FIG. 2), in accordance with one embodiment of the invention. As mentioned above, if a particular used free section 604 is dirty (not clean) (see Task 403), this means that the BlkInfoDirBlk and the DirBlk blocks saved in the non-volatile memory associated to that particular used free section 604 (also in the non-volatile memory) needs to be updated. FIG. 6 shows the update for the BlkInfoDirBlk (information directory block) during a power cycle recovery sequence, while FIG. 7 shows the update for DirBlk (directory block) during a power cycle recovery sequence.

As stated above, if the used free section is dirty Task 403, then the information directory block (BlkInfoDirBlk) saved in non-volatile memory associated with that used free section is updated or is verified as updated with the Task 410 shown in FIG. 6. Additionally, if a free section 504 (FIG. 5) (added to the free list block 500) is clean in Task 408, then the BlkInfoDirBlk saved in non-volatile memory associated with that added free section 504 is updated or is verified as updated with the Task 410 shown in FIG. 6. In FIG. 6, the BlkInfoDirBlk 216 (FIG. 2) associated for the aforementioned used free section 604 is made available in cache in task 600 (FIG. 6). In FIG. 6, the legend “CB” means cache block information or volatile memory block information (i.e., BlkInfoDirBlk in volatile memory such as, for example, a cache). As similarly discussed above, this aforementioned used free section 604 is pointed to by one of the free list entries F that are candidates 503 (FIG. 5) for removal in the list. The system then looks for the BlkInfoDirEntry associated with the aforementioned used free section 604 in task 601. As discussed above, the BlkInfoDirEntry is an entry 217 in the BlkInfoDirBlk 216 (FIG. 2).

The InvalidBitMap flag 603 is associated with the aforementioned used free section 604 and is in the BlkInfoDirEntry. The system then checks, in task 602, if the InvalidBitMap flag 603 is not set because the aforementioned used free section 604 is in its used state. If the InvalidBitMap flag 603 is not in same state with that of the aforementioned used free section 604, the InvalidBitMap flag 603 is set (updated) to “0” in task 605, so that the flag 603 is updated to the current state which is the used state. The system then exits this process and returns to the main program of FIG. 4A. In task 602, if the InvalidBitMap flag 603 is in same state (used state) with that of the aforementioned used free section 604, then this condition means that the BlkInfoDirEntry has previously been updated and no update is required for the BlkInfoDirBlk associated with the used free section 604. When the BlkInfoDirEntry has previously been updated, then the process exits and returns to the main program of FIG. 4A. Therefore, the process in FIG. 6 is performed to update the BlkInfoDirBlk associated with the used free section 604 if this update is needed, or is performed to verify the previous update of that BlkInfoDirBlk.

FIG. 7 is a flow diagram of the power cycle recovery sequence for updating a DirBlk, in accordance with one embodiment of the invention. In FIG. 7, the legend “CD” means cache directory or volatile memory directory (i.e., directory in volatile memory), the legend “CS” means cache section or volatile memory section (i.e., data section in volatile memory), and the legend “CF” means cache free list entry or volatile memory free list entry (i.e., free list entry in volatile memory). If a particular used free section is dirty (see Task 403) and after the power cycle recovery sequence for the BlkInfoDirBlk is performed (FIG. 6), the sequence for DirBlk is executed in order to perform an update on the DirBlk if needed. FIG. 7 details the DirBlk power cycle sequence. First in task 700, the system reads, from a DirBlk in volatile memory (e.g., a cache), the logical block address (Lba) 701 and the displaced physical block address (DisplacedPba) 702 in the aforementioned used free section 604 (which also shown in FIG. 6) that is dirty. As discussed above with reference to FIG. 2, a directory entry (DirEntry) in a DirBlk 202 points to a used free section 211 which contains an Lba and a DisplacedPba, where the DisplacedPba is the PBA of the last data section associated to the Lba.

Then in task 704, the system checks if the User Data 705 (of the used free section 604) is error free (valid). If the user data 705 turns out to be invalid, the system exits this process and returns to the main program in FIG. 4A without updating the DirBlk.

An invalid user data 705 indicates that the writing of the user data (into the used free section 604) was not yet finished when system power interruption occurred, and as a result the DirBlk associated with the used free section 604 is not updated. Otherwise, the system makes available the DirBlk associated to the aforementioned used free section 604 in cache, as shown in task 706.

In task 707, the system looks (searches) for the DirEntry 708 which is associated with the used free section 604. The system then reads the Pba 709 of the DirEntry 708. In task 710, the system checks whether the Pba 709 is matched with the associated Pba of the Lba 701 of the used free section 604. If the above physical block addresses (Pbas) are matched, this means that the DirBlk (associated with the used free section 604) in the non-volatile memory is already updated and the system exits this process and returns to the main program in FIG. 4A. Otherwise, if the above Pbas do not match in task 710, then in task 711 the system compares the used free section pointed to by the used free section index (SecIdx) 712 in the FreeLstEntry 720 and the used free section pointed to by Pba 709. As shown in FIG. 2 and FIG. 5, the section index is contained in a free list entry in a free list block. If, in task 713, the section pointed to by the SecIdx 712 is newer than the section pointed to by the Pba 709, then this means that the aforementioned DirBlk is updated and the system exits this process. Otherwise, if the section pointed to by the SecIdx 712 is not newer than the section pointed to by the Pba 709, then the system executes the task 714 where the system replaces the Pba 709 content of the DirEntry 708 with the SecIdx 712 so that the Pba 709 points to the section pointed to by SecIdx 712. The PBA 709 content in the DirEntry 708 (FIG. 7) needs to be replaced because the system has determined that the PBA 709 content is old. The PBA 709 content is required to be replaced by a new PBA content which comes from the PBA in the current FreeList Section index (SecIdx) 712 which the system is scanning in the cache. The SecIdx 712 does not point to an older section and it points to a newer section than the section being pointed to by the PBA 709 content.

FIG. 8 is a flow diagram of a method of comparison between physical block address, in accordance with one embodiment of the invention. The legend “FS to CS” in FIG. 8 means the system will read from a non-volatile memory section (e.g., flashchip section) and then the content is written to the volatile memory section (e.g., cache section). Also, prior to the start of Task 800, the DirEntry is already stored in volatile memory (e.g., cache). If the DirEntry is not yet in the volatile memory prior to the start of Task 800, then the system will read the DirEntry from the non-volatile memory (e.g., flashchip) to obtain the DirEntry content. This method provides the details of the task 713 of FIG. 7, to compare the sections pointed to by the SecIdx 712 and Pba 709. This task 713 is usually performed after determining that the aforementioned used free section 703 (FIG. 7) pointed to by the SecIdx 712 (in the FreeLstEntry 720) is not actually free. Moreover, this task 713 determines if the aforementioned pointed section 703 is newer compared to that of the section 604 (FIG. 7) pointed by the DirEntry 708. In other words, the system determines if the section Pba from the FreeLstEntry 720 (as derived from the non-volatile memory block Pba and section index 712) is new. There are three possible outputs as illustrated in the three cases shown in FIG. 9. The three outputs can be: (1) if the section pointed by the FreeLstEntry and by the DirEntry is equal, then there is no need to update the DirBlk; (2) if the section pointed by the FreeLstEntry is new, then the system updates the DirBlk; and (3) if the section pointed by the FreeLstEntry is invalid, then the system updates the BlkInfoDirBlk.

Referring now to FIG. 9, there is shown a block diagram illustrating the different cases of when to update the BlkInfoDirBlk and the DirBlk, in accordance with one embodiment of the invention. This first case (case1) 900 is a possible case during the system's traversing of the sections as indicated in reference block 910. In the first case (Case1) 900, the section (S) pointed by the DirEntry 901 (in a DirBlk) is the same section (S) pointed to by the FreeLstEntry 902 (in a FreeLstBlk). For this first case 900, the updates of either the BlkInfoDirBlk or DirBlk are unnecessary. In this case 900, the section 915 pointed to by the FreeLstEntry 902 is new, but the DirBlk is already updated and therefore, no update is required for the DirBlk.

The second case (case2) 903 is another possible case during the system's traversing of the sections as indicated in reference block 911. In the second case (Case2) 903, the section pointed to by the FreeLstEntry 905 is not equal to the section pointed to by the DirEntry 904 and is newer than the section pointed to by the DirEntry 904. For this case 903, the DirBlk requires an update.

The third case (case3) 906 is another possible case during the system's traversing of the sections as indicated in reference block 912. In the third case (Case3) 906, the section pointed to by the FreeLstEntry 907 is invalid (i.e., the section 51 pointed to by the DirEntry 908 is newer than the section S2 pointed to by the FreeLstEntry 907). For this case 906, the BlkInfoDirBlk needs an update. For example, the section S1's InvalidBitMap 218 (FIG. 2) in a BlkInfoDirEntry block (in BlkInfoDirBlk 216) must be set to the invalid state.

Reference is now made to both FIG. 7 and FIG. 8. As noted above, the process in FIG. 8 are the steps in task 711 (FIG. 7), where the system will compare the sections pointed to by the Section index (SecIdx) 712 and the Pba 709. Other conditions or definitions are indicated in reference block 810 for the method in FIG. 8. Note also that in FIG. 8, at the start in block 800, the system will read, from the flash memory to the cache, the section pointed by “Given”, where the reference block 810 defines “Given” as the Section Pba from the FreeListEntry derived from Block Pba plus (+) the Section index. In FIG. 8, the legend “FS to CS” denotes reading from the non-volatile section (e.g., flash section) to the volatile section (e.g., cache section). If the DirEntry is not in the volatile section, then the system obtains the DirEntry from the non-volatile section. Note also that in FIG. 8, the system has already compared the Lba because FIG. 8 is a process performed in block 711. The method of FIG. 8 starts by the system reading, from cache, the section pointed by a given Section Pba from the FreeLstEntry 902 (FIG. 9) in task 800. In task 801, the logical block address (LBA) of the section being pointed by the “Given” (reference block 810) is saved as Compare LBA (CompLBA). Then in task 802, the physical block address (PBA) associated with the compare LBA (CompLBA) is read and is compared with the PBA from the DirEntry 901 (FIG. 9) in task 803. Since in task 801, the LBA (which is pointed to by FreeLstEntry 902) is saved as CompLBA, the FreeLStEntry 902 is associated with the above-mentioned PBA associated with the CompLBA. If the PBA (“given Section Pba”) associated with the compare LBA (CompLBA) is equal to the PBA from the DirEntry 901, there is no need for any updates because the DirBlk is already updated as shown in case1 900 of FIG. 9. On the other hand, if the given PBA associated with the compare LBA is not equal to the PBA from the DirEntry 901, the DisplacedPba of the last section in volatile memory (e.g., cache) is set as the current displaced PBA (CurrDisplacedPba) 726 (in FIG. 7) in task 804. Therefore, in task 804, the system again reads the non-volatile memory (e.g., flashchip), obtains the previous section's Pba (which was labeled above as DisplacedPba), and saves this DisplacedPba as CurrDisplacedPba. Therefore, the CurrDisplacedPba indicates a Pba of a particular section as the system is traversing the sections read from non-volatile memory as discussed FIGS. 8 and 9.

In task 805, the system evaluates if this DisplacedPba (which the system had obtained via traversal to the previous section in non-volatile memory and had saved in CurrDisplacedPba) is equal to the Pba in the DirEntry. If in task 805, the CurrDisplacedPba is equal to the PBA from the DirEntry, then the DirBlk 904 needs to be updated in accordance with case2 903 (FIG. 9) because the section S pointed by the FreeLstEntry 905 is newer than section 920 pointed to by the Pba from the DirEntry in DirBlk 904; otherwise, the system checks if the section in non-volatile memory pointed to by the CurrDisplacedPba is clean or erased in task 806. Note also that in task 806, the CurrDisplacedPba did not yet match a Pba from the DirEntry. If this section pointed to by the CurrDisplacedPba is already clean (as shown by erased section 925), then the section pointed to by the FreeLstEntry 907 is invalid, and therefore, the BlkInfoDirBlk needs to be updated in its invalid bit map value 218 (FIG. 2) in accordance with case3 906; otherwise, this aforementioned section (pointed by the CurrDisplacedPba) is read from cache in task 807. Note that in task 806, if the CurrDisplacedPba section is clean or erased, then a criteria (case1) 908 (FIG. 9) for the system to end the search (traversal) of the sections in non-volatile memory has been satisfied (see also reference block 914). When the criteria 908 has been satisfied, the system has traversed to the erased section F (free section F), and the system will then end the search of the sections and will not update the DirBlk 908, since the system did not find any section (identified as CurrDisplacedPba section during traversal) that matched the Pba from DirEntry 908. Referring back to task 806, if the CurrDisplacedPba section is not erased, then the system performs task 807. The system reads from the volatile memory (e.g., cache) the section pointed to by the CurrDisplacedPba in task 807. The Lba from the aforementioned section is then compared with the compare LBA in task 808. If the compare LBA is not equal to the LBA from the said section, then the BlkInfoDirBlk needs to be updated. The searching for Case1 900 ends when the section pointed by the DiplacedPba is already erased as illustrated in case1 908. Furthermore, the searching for Case2 903 ends when the section pointed by the DisplacedPba is associated in a different LBA as illustrated in case2 909 because this Lba mismatch may indicate, for example, that the section contains another user data (see also reference block 916). In case2 909, the system has traversed to the last section S on the left, and the Lba of this last section is different from the Lba of the section pointed by the Pba from the FreeLstEntry 907. The system will end its search (traversal) of the sections when this mismatch of LBAs occurs in task 808.

When the free list 902 (FIG. 9) is pointing to the same section 915 as the directory entry 901, the DirBlk is already updated. Therefore, the task 803 returns a case1 900 where the DirBlk is not updated.

When the free list 905 (FIG. 9) backward traverses the previous sections S and when the Pba of the directory entry 904 at section 920 matches the CurrDisplacedPba of the free list 905, the system returns a case2 903 because the Pba of the directory is old and an update will, therefore, be required for the DirBlk. Note that the Pba (CurrDisplacedPba) of the free list 905 is displaced due the backward traversal of the free list 905).

When the free list 907 (FIG. 9) backward traverses the previous sections S and when the CurrDisplacedPba of the free list 907 does not match the Pba of the directory entry 908 at section S1 and when the CurrDisplacedPba of the free list 907 matches an erased section 925, the system returns a case3 906 as discussed above in paragraph 60.

The system loops back from task 808 to task 804 if, in task 808, the compare LBA is equal to the LBA from the section pointed by the CurrDisplacedPba. The system performs this loop until the criteria in task 805 or task 808 is satisfied.

After the system performs the above tasks 713 and 714, the system then exits this process in FIG. 7 and returns to the main program of FIGS. 4A-4B. Tasks 401 to 405 of FIG. 4A loops until all the free list entries that are candidates for removal are determined. After this determination, the system proceeds the scanning of the FreeLstBlk from the pointer 502 up to the entry pointed to by the index 501 (right to left), to determine if the free sections are clean as shown in FIG. 5. For example in FIG. 5, after the FreeLstEntries 503 that are candidates for removal are replaced with new set of free sections 504 pointed to by FreeLstEntries, the system checks the section pointed to by the FreeLstEntry in task 406 (FIG. 4B). Then in task 407, the system verifies if the section is indeed clean or erased. If the section turns out to be dirty in task 408, the system erases this section in task 409; otherwise, the BlkInfoDirBlk power cycle recovery section of FIG. 6 is again executed in task 410. Tasks 406 to 410 will loop 415 until the section pointed to by the FreeListEntry is proven to be clean. The system then exits this process of FIGS. 4A-4B.

After the process illustrated in FIGS. 4A-4B is performed, the system proceeds with performing any processes that were interrupted during the power failure of the system.

Typically, every time the control blocks in cache become dirty, the control blocks stored in non-volatile memory are also updated. However, for very hierarchical directory structures, constant updates are inefficient as discussed above. Consequently, an embodiment of the present invention implements the following thresholds and background tasks that allow the sequences to be sufficiently adaptive to determine when these directories need to be updated, thereby minimizing directory updates. Background tasks preferably occur when the system is, for example, idle.

TABLE 1 Threshold for FreeLstBlk Update When to update the FreeLstBlk saved in the non-volatile memory [1] Due Update the FreeLstBlk saved in the non-volatile memory, due to the update of FreeLstBlk in volatile memory (e.g., cache) of which it should preferably always be the same.

In the discussion below and in other parts of this disclosure, the term “cache” can also mean other suitable types of volatile memory. Table 1 illustrates an example threshold for the FreeLstBlk update. The FreeLstBlk 500 (FIG. 5) in cache is updated when the free count threshold is reached. For example this threshold is reached when the free sections pointed to (by the FreeLstBlk) are almost empty. For example, in a 64 GB disk size, the reserved space for free sections is about 1 GB and every FreeLstEntry consumes about 4 KB; hence, there will be about 262,144 FreeLstEntry entries. If the threshold for the used free sections is 80% of 262,144, this means that there will be 209,715 write commands that occurred before an update of FreeLstBlk. The threshold can be set to other values such as approximately 75% or other threshold values. This threshold can be configured in, for example, in a firmware that is loaded in the system. Therefore, the amount of used free sections (dirty section) accumulated in cache (due to an update of FreeLstBlk in cache) will need to reach a threshold, as discussed above, before an update is performed on the FreeLstBlk saved in the non-volatile memory (e.g., flash memory).

TABLE 2 Threshold for BlkInfoDirBlk Update When to update the BlkInfoDirBlk saved in the non-volatile memory [1] Due to the update of FreeLstBlk of which BlkInfoDirBlk is dependent. [2] The BlkInfoDirBlk in the cache is candidate for update due to lack of free BlkInfoDirBlk in the cache. [3] If the BlkInfoDirBlk in the cache is too dirty. This update is only performed during background task.

Similarly, if the BlkInfoDirBlk is fully cached, condition [2] of Table 2 is not performed; otherwise, an update of BlkInfoDirBlk in non-volatile is performed. Otherwise stated, in condition [2], the BlkInfoDirBlk saved in the non-volatile memory is updated when there is a lack of free BlkInfoDirBlk in the cache. A cache coherency algorithm program, as known to those skilled in the art, can be used to perform the functions as stated in condition [2].

The BlkInfoDirBlk in cache is also updated in the non-volatile memory when the FreeLstBlk is updated of which the BlkInfoDirBlk is dependent as stated in condition [1].

The BlkInfoDirBlk is also updated in the non-volatile memory when condition [3] is satisfied, where a threshold value (e.g., approximate 75%) of the BlkInfoDirBlk in the cache is dirty. This update of the BlkInfoDirBlk in the non-volatile memory is preferably only performed in, e.g., the background task.

TABLE 3 Threshold for DirBlk Update When to update the DirBlk saved in the non-volatile memory [1] Due to the update of FreeLstBlk of which DirBlk is dependent. [2] The DirBlk in the cache is candidate for update due to lack of Free DirBlk in the cache. [3] If the DirBlk in the cache is too dirty. This is only done during background task.

Similarly, if the DirBlk is fully cached, condition [2] of Table 2 is not performed; otherwise, an update of DirBlk in non-volatile memory is performed. The DirBlk in cache is updated in non-volatile memory when the FreeLstBlk is updated of which the DirBlk is dependent as stated in condition [1]. The DirBlk is also updated when condition [3] is satisfied.

FIG. 10 is a block diagram of a normal operation update for a FreeLstBlk, in accordance with one embodiment of the invention. This FreeLstBlk update sequence and data recovery is performed during boot-up whenever the power fails during the execution of the update process. This sequence in FIG. 10 will flush out all dirty DirBlk, FreeLstBlk, and BlkInfoDirBlk blocks. Additionally, in an embodiment of the invention, when the system updates the free list block (FreeLstBlk) 203 (FIG. 2), the system will also update the directory block (DirBlk) 202 and block information directory block (BlkInfoDirBlk) 216, in order to maintain proper synchronization of these blocks and perform proper updates as discussed above. The legend “CB to FB” means cache block information to flashchip block information. The legend “CD to FD” means cache directory to flashchip directory. The legend “FF” means flashchip free list, while the legend “CF” means cache free list. First, the system collects all the invalid sections ready for erase in task 1000. Then in task 1001, all dirty DirBlk in the non-volatile memory is updated using a suitable redundant recovery method such as, for example, the redundant recovery sequence of FIG. 3. Similarly in task 1002, all dirty BlkInfoDirBlk in the non-volatile memory is updated using a suitable redundant recovery method such as, for example, the sequence of FIG. 3. Note also that other possible conditions or details are shown in at least some of the reference blocks 1010, 1011, 1012, 1013, 1014, 1015, 1016, and 1017 in the method of FIG. 10.

Reference is now made to both FIG. 10 and FIG. 11. As shown, FIG. 11 is a block diagram of an itemized illustration of FreeLst update of FIG. 10, in accordance with one embodiment of the invention. In task 1003, the system replaces the used FreeLstEntries covered from the entry pointed by the index 1102 up to the FreeLstEntry before the pointer 1103 as shown in FIG. 11. However, prior to the above-replacement of the used FreeLstEntries, the FreeLstBlk in non-volatile memory 1100 is mirrored to cache 1101. In the FreeList composition of FIG. 11, each number (numeral) in the drawing contains a Block PBA pointed to one free block. Initially, the index 1102 points to the very first free FreeLstEntry 1120. As the FreeLstEntries are being used up, the pointer 1103 increments. After sometime, when the threshold 1104 (for example, eight (8) used FreeLstEntry) is reached, the aforementioned FreeLstBlk needs an update in non-volatile memory (e.g., flashchip or any other suitable type of non-volatile memory). Then in task 1004 (FIG. 10), the system updates the FreeLstBlk in the non-volatile memory using a suitable redundant recovery method such as, for example, the sequence of FIG. 3 (i.e., the FreeLstBlk in the cache is written to the non-volatile memory 1105). The value of the FreeLst index 1102 is then changed to be equal to the value of the pointer 1106 in task 1005. As shown in FIG. 11, the index 1102 and pointer 1106 have the same value of entry (9) 1125. The FreeLst counter 1102 is then set to 0 in task 1006. The system erases the invalid blocks in the non-volatile memory for compacting or garbage collection in task 1007. Furthermore in task 1008, the system sets the InvalidBitMap flag to 0, meaning the sections are set to valid. Finally in task 1009, since the BlkInfoDirBlks are modified by executing task 1008, the system updates all the dirty BlkInfoDirBlk using the redundant recovery method. The redundant recovery method is used in task 1009 so that a write is not performed in any free list sections, since writing to a free list section will affect the upstream nodes in a directory tree.

Additionally, in Task 1000, the BlkInfoDirBlk and the DirBlk can be recovered during initialization of system in FIG. 4. In Task 1001, the BlkInfoDirBlk can be recovered during initialization of system in FIG. 4. In Task 1002, the DirBlk can be recovered during initialization of system in FIG. 4. In Task 1009, the BlkInfoDirBlk can be recovered during initialization of system in FIG. 4.

FIG. 12 is a block illustration of a data relocation, in accordance with one embodiment of the invention. This drawing in FIG. 12 particularly illustrates another normal operation that performs the frequent updates of the sections. Unlike the control blocks update that uses the redundant recovery sequence of FIG. 3, the sections are updated by relocation because it is inefficient to use the aforementioned redundant method of FIG. 3 because the sections are always updated every now and then or more frequently.

Reference is now made to FIG. 12 and FIG. 13. As shown, FIG. 13 is a flowchart of the data relocation process illustrated in FIG. 12, in accordance with one embodiment of the invention. Also shown in FIG. 13 is the data recovery sequence whenever the power fails during the execution of the aforementioned update process. Other possible details or conditions in the method of FIG. 13 are shown in at least some of the reference blocks 1307, 1308, 1309, 1310, 1311, 1312, and 1313. First, the system in task 1300 asks for free section 1200 (FIG. 12) in the FreeLstBlk. Then in task 1301, the system makes the associated DirBlk for the given LBA by the host (non-volatile memory) to be available in cache. Prior to task 1301, this associated DirBlk is not yet in cache. However, if DirBlk is already available in cache, then there is no need to obtain this content from the non-volatile memory. Therefore, the task 1301 is already satisfied and not performed if DirBlk is already in cache.

In task 1302, the system then obtains the old PBA of the associated LBA of the previous section 1201 (shown as user section 1201 in FIG. 12A). Then in task 1303, the system modifies the LBA and the DisplacedPba in the statistics of the section in cache (i.e., the previous PBA is now equal to the DisplacedPba of the new section). Then in task 1304, in process 1210, the new data 1202 for used section 1201 is written to a free section 1200. If, for example, the power fails in the middle of writing the new data 1202 to the free section 1200, the old data in used section 1201 is still considered valid.

Note further that tasks 1300, 1301, 1302, 1303, and 1304 use information in the control blocks of the old data 1201 in order to perform the operations associated with these tasks. The information needed in old data 1201 is the Lba and the DisplacedPba.

In process 1215, after assuring that all new data 1202 has been written to free section 1200, the old used section 1201 can now be erased and marked as a new free section 1203 and now ready to carry new data (i.e., the system modifies the PBA of the DirEntry to the new given free section's PBA in task 1305; and in task 1306, the system also sets the InvaldiBitMap of the BlkInfoDirBlk of the old section to invalid). As long as a section has never been marked as free in the event of power failure, this old data will still be valid. The conversion of old sections to free sections is performed in one action so that when power fails, all sections are synchronized as either old or new. In the event of power failure occurring during this data relocation process, the redundant data recovery method is executed. Data recovery is performed during start-up in which the system will first read the content of the free sections one by one to determine whether it contains a valid data. If a free section contains a valid data it will be marked as a used section 1204.

Note that in task 1305, the DirBlk (in cache) will be recovered during the system initialization and the free list detects the free section as not actually free as shown in FIG. 11.

In task 1306, the BlkInfoDirBlk (in cache) will be recovered during the system initialization and the free list detects the free section as not actually free and contains a displaced Pba as shown in FIG. 10.

FIG. 14 is a block diagram of an example storage system (or storage device) 1400, in accordance with one embodiment of the invention. This example system 1400 is configurable to perform the data recovery functions or features described herein.

Typically, the storage device 1400 is coupled to a host 1402 through a peripheral interface 1404, such as SCSI, Fibre Channel, ATA, IDE, and/or the like, permitting the host 1402 to perform storage operations on the storage device 1400, such as write and read operations. The storage device 1400 is shown having a Memory A 1406, a Memory B 1408, a system bus, a memory bus, a local processor 1418 and associated circuitry. In addition, a Processor Circuit 1424, a Local Processor Memory 1422, a ROM 1420, and their general interaction with the storage device 1400 appear in the block diagram but are not described to avoid overcomplicating the herein disclosure. Additionally, some of the elements or components in the storage device 1400 can be varied or substituted in a manner that would achieve the functions or operations described herein.

In one embodiment, the Memory A 1406 typically includes at least one bank of NAND Flash memory 1410 and a flash memory buffer circuit 1412, which is coupled to a memory controller 1414, such as, for example, a DMA controller. The Memory A 1406 is intended for use as the primary storage memory of the device 1400 and more than one set may be used to increase capacity and/or performance. In the previous discussion above, the memory 1410 is referred to as a non-volatile memory. As one example, this non-volatile memory that forms the memory 1410 is a flashchip, although this non-volatile memory may be other suitable types of memory devices. In one embodiment, one DMA controller is used for every set implemented.

The Memory B 1408 typically includes a DRAM (or its equivalents, such as SDRAM, RDRAM, etc.) and is used as a read/write (“storage”) cache to Memory A 1406. In the previous discussion above, the Memory B 1408 is a volatile memory such as, for example, a cache as also referred to in the previous discussion above. The Memory B 1408 can also be other suitable types of volatile memory. The Memory B 1408 is controlled by at least one DMA memory controller (not shown) although more than one controller may be used to increase performance. Two DMA controllers (not shown) are used and provided using the local processor, which is, for example, a RISC processor having two embedded DMA controllers or other suitable processors.

The conduit between the peripheral interface 1404 is a simplified representation of a peripheral bus 1430 and may include switches, routers, and network devices but are not shown to avoid complicating the herein disclosure. For example, if the peripheral interface 1430 is implemented using a fibre channel interface, then at least one port provided by a switch would be part of the conduit between the peripheral interface and the host.

It is also within the scope of the present invention to implement a program or code that can be stored in a machine-readable or computer-readable medium to permit a computer to perform any of the inventive techniques described above, or a program or code that can be stored in an article of manufacture that includes a computer readable medium on which computer-readable instructions for carrying out embodiments of the inventive techniques are stored. Other variations and modifications of the above-described embodiments and methods are possible in light of the teaching discussed herein.

The above description of illustrated embodiments of the invention, including what is described in the Abstract, is not intended to be exhaustive or to limit the invention to the precise forms disclosed. While specific embodiments of, and examples for, the invention are described herein for illustrative purposes, various equivalent modifications are possible within the scope of the invention, as those skilled in the relevant art will recognize.

These modifications can be made to the invention in light of the above detailed description. The terms used in the following claims should not be construed to limit the invention to the specific embodiments disclosed in the specification and the claims. Rather, the scope of the invention is to be determined entirely by the following claims, which are to be construed in accordance with established doctrines of claim interpretation. 

What is claimed is:
 1. A method for maintaining data, the method comprising: accessing a free list associated with a non-volatile memory (NVM), wherein the NVM includes a plurality of NVM blocks, wherein each of the plurality of NVM blocks includes a plurality of NVM sections, and wherein the free list includes one or more free list entries, wherein each free list entry corresponds to a free block and points to a free section within the free block, wherein each free block comprises an NVM block comprising one or more free sections, wherein each free section comprises an NVM section not associated with a logical address; maintaining a state map, wherein the state map indicates a validity state for each of the plurality of NVM sections; maintaining a directory identifying allocated sections of the NVM, wherein the directory includes a plurality of directory entries, wherein each directory entry indicates a physical address of an allocated section, wherein each allocated section comprises an NVM section associated with a logical address; for one or more of the free list entries, performing first scanning operations and second scanning operations, wherein: the first scanning operations include: scanning allocated sections in the free block to identify dirty sections, wherein each dirty section comprises an allocated section containing user data; and for each dirty section, performing free list removal operations including: performing map update operations to set the state map information for the dirty section to reflect a current validity state of the dirty section; and performing directory update operations to update a directory entry associated with the dirty section; and the second scanning operations include: scanning allocated sections in the free block to identify dirty sections and clean sections; erasing each of the dirty sections; and performing the map update operations for each of the clean sections.
 2. The method of claim 1, further comprising: maintaining a control block, wherein the control block includes: a directory pointer indicative of an address of the directory; and a free list pointer indicative of an address of the free list.
 3. The method of claim 1, further comprising: performing the first scanning operations and the second scanning operations for each of the free list entries.
 4. The method of claim 1, wherein the state map includes a map directory, wherein the map directory includes a plurality of map directory entries, wherein each map directory entry corresponds to an NVM block and wherein each map directory entry comprises a bit map comprising a plurality of bit map values, including a bit map value corresponding to each section in the NVM block, wherein each bit map value indicates a validity state of the corresponding section.
 5. The method of claim 4, wherein performing the map update operations for a particular section of a particular NVM block include: accessing the bit map for a particular map directory entry corresponding to the particular NVM block; retrieving a particular bit map value from the bit map; and comparing the a validity state associated with the particular bit map value with a validity state of the particular section.
 6. The method of claim 1, wherein performing the directory update operations comprises: comparing a first physical address with a second physical address, wherein the first physical comprises a physical address of the dirty section determined from the free list entry and wherein the second physical address comprises an address indicated in the directory entry; responsive to determining that the first physical address differs from the second physical address, determining whether a first section of the NVM, comprising a section at the first physical address, is newer than a second section of the NVM, comprising a section at the second physical address; responsive to determining that the first section is not newer than the second section, modifying the directory entry to point to the first physical address.
 7. The method of claim 6, wherein the free list entry is associated with an NVM block and wherein the first physical address is determined based on a physical address of the NVM block and an index value. 